<template>
  <div class="auth">
    <div class="container">
        <div class="form row">
            <div class="form-horizontal col-md-offset-3" id="login_form">
                <h3 class="form-title">LOGIN</h3>
                <div class="col-md-9">
                    <div class="form-group">
                        <i class="fa fa-user fa-lg"></i>
                        <input class="form-control required" type="text" placeholder="Username" id="username" name="username" autofocus="autofocus" maxlength="20"/>
                    </div>
                    <div class="form-group">
                        <i class="fa fa-lock fa-lg"></i>
                        <input class="form-control required" type="password" placeholder="Password" id="password" name="password" maxlength="8"/>
                    </div>
                    <div class="form-group">
                        <label class="checkbox">
                            <input type="checkbox" name="remember" value="1"/>记住我
                        </label>
                    </div>
                    <div class="form-group col-md-offset-9">
                        <button type="submit" class="btn btn-success pull-right" @click="handleLogin" name="submit">登录</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
  </div>
</template>
<script>
    export default {
      data () {
        return {
          loginForm : {
            name : 'lidong',
            password : '123'
          }
        }
      },
      methods:{
        handleLogin () {
          this.$store.dispatch('LoginByUsername', this.loginForm).then( () => {
            this.$router.push({ path: '/page' })
          }).catch(() => {
            alert('some thing is wrong');
          })
        }
      }
    }
</script>
<style>

</style>
